﻿
		<select id="gid" name="gid" class="input input-auto hidden" >
		</select>
		<select id="cateid" name="cateid" class="input input-auto hidden" >
		</select>
<script id="gid_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
		<option {{# if(d.data[i].id==gid){ }}selected{{# } }} value="{{ d.data[i].id }}">{{ d.data[i].title }}</option>
	{{# } }}
</script>
<script id="cateid_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
		<option {{# if(d.data[i].id==cateid){ }}selected{{# } }} value="{{ d.data[i].id }}">{{ d.data[i].title }}</option>
	{{# } }}
</script>
<script>
	var func = false;
	$('select').click(function(){
		func = true;
	});
	$.getJSON('__ROOT__/seller/{$Request.controller}/ajax_get', {}, function(res){
		if(res.data.length > 0 ){
			var tpl = $("#gid_list_tpl").html();
			laytpl(tpl).render(res, function(render){
				$("#gid").html(render);
			});
			$('[name=gid]').removeClass('hidden');
			$('[name=gid]').change();
		}else{
			$('[name=gid]').addClass('hidden');
		}
	});
	$('[name=gid]').change(function(){
		gid = $(this).val();
		if(selectc == true){
			$.getJSON('__ROOT__/seller/{$Request.controller}/ajax_get?id='+gid, {}, function(res){
				if(res.data.length > 0 ){
					var tpl = $("#cateid_list_tpl").html();
					laytpl(tpl).render(res, function(render){
						$("#cateid").html(render);
					});
					if(selectc == true){
						$('[name=cateid]').removeClass('hidden');
						$('[name=cateid]').change();
					}
				}else{
					$('[name=cateid]').addClass('hidden');
				}
			});
		}
		if(func == true){
			select_g();
		}
	});
	$('[name=cateid]').change(function(){
		cateid = $(this).val();
		if(func == true){
			select_c();
		}
	});
</script>